﻿@using Yuebon.Commons.Helpers
@using Microsoft.AspNetCore.Http
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>@ViewData["Title"]</title>
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <link rel="stylesheet" href="~/lib/bootstrap/css/bootstrap.css" />
    <!-- Font Awesome -->
    <link rel="stylesheet" href="~/lib/font-awesome/css/fontawesome-all.min.css">
    <link rel="stylesheet" href="~/lib/select2/select2.css">
    <link rel="stylesheet" href="~/lib/iCheck/minimal/minimal.css">
    <link rel="stylesheet" href="~/lib/iCheck/minimal/blue.css">
    <link rel="stylesheet" href="~/css/adminlte.css" />
    <link rel="stylesheet" href="~/lib/toastr/toastr.min.css">
    <link rel="stylesheet" href="~/css/site.css" />


    <!-- bootstrap table -->
    <link rel="stylesheet" href="~/lib/bootstrap-table/bootstrap-table.min.css">

    <!-- jQuery -->
    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script src="~/lib/popper/umd/popper.min.js"></script>
    <!-- Bootstrap 4 -->
    <script src="~/lib/bootstrap/js/bootstrap.js"></script>
    <script src="~/lib/bootstrap-table/bootstrap-table.js"></script>
    <script src="~/lib/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="~/lib/iCheck/icheck.min.js"></script>
    <script src="~/lib/select2/select2.min.js"></script>
    <script src="~/lib/jquery.cookie.js"></script>
    <script src="~/lib/toastr/toastr.min.js"></script>
    <script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
    <script src="~/lib/jquery-validation/dist/additional-methods.js"></script>
    <script src="~/lib/sweetalert.min.js"></script>

    <!-- FastClick -->
    <script src="~/lib/fastclick/fastclick.js"></script>
    <script src="~/js/adminlte.js"></script>
    <script src="~/js/demo.js"></script>
    <script src="~/js/app.js"></script>
    <script src="~/js/site.js"></script>
</head>
<body class="hold-transition sidebar-mini">
    <div class="wrapper">
        <!-- Navbar -->
        <nav class="main-header navbar navbar-expand bg-white navbar-light border-bottom">
            <!-- Left navbar links -->
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" data-widget="pushmenu" href="#"><i class="fa fa-bars"></i></a>
                </li>
                <li class="nav-item d-none d-sm-inline-block">
                    <a href="/Home/Index" class="nav-link">Home</a>
                </li>
                <li class="nav-item d-none d-sm-inline-block">
                    <a href="/Home/about" class="nav-link">关于</a>
                </li>
            </ul>
            <!-- SEARCH FORM -->
            <form class="form-inline ml-3">
                <div class="input-group input-group-sm">
                    <input class="form-control form-control-navbar" type="search" placeholder="Search" aria-label="Search">
                    <div class="input-group-append">
                        <button class="btn btn-navbar" type="submit">
                            <i class="fa fa-search"></i>
                        </button>
                    </div>
                </div>
            </form>
            <!-- Right navbar links -->
            <ul class="navbar-nav ml-auto">
                <!-- 系统消息 -->
                <li class="nav-item dropdown">
                    <a class="nav-link" data-toggle="dropdown" href="#">
                        <i class="fas fa-comments"></i>
                        <span class="badge badge-danger navbar-badge">3</span>
                    </a>
                    <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
                        <a href="#" class="dropdown-item">
                            <!-- Message Start -->
                            <div class="media">
                                <img src="~/img/user1-128x128.jpg" alt="User Avatar" class="img-size-50 mr-3 img-circle">
                                <div class="media-body">
                                    <h3 class="dropdown-item-title">
                                        Brad Diesel
                                        <span class="float-right text-sm text-danger"><i class="fa fa-star"></i></span>
                                    </h3>
                                    <p class="text-sm">Call me whenever you can...</p>
                                    <p class="text-sm text-muted"><i class="fa fa-clock-o mr-1"></i> 4 Hours Ago</p>
                                </div>
                            </div>
                            <!-- Message End -->
                        </a>
                        <div class="dropdown-divider"></div>
                        <a href="#" class="dropdown-item">
                            <!-- Message Start -->
                            <div class="media">
                                <img src="~/img/user8-128x128.jpg" alt="User Avatar" class="img-size-50 img-circle mr-3">
                                <div class="media-body">
                                    <h3 class="dropdown-item-title">
                                        John Pierce
                                        <span class="float-right text-sm text-muted"><i class="fa fa-star"></i></span>
                                    </h3>
                                    <p class="text-sm">I got your message bro</p>
                                    <p class="text-sm text-muted"><i class="fa fa-clock-o mr-1"></i> 4 Hours Ago</p>
                                </div>
                            </div>
                            <!-- Message End -->
                        </a>
                        <div class="dropdown-divider"></div>
                        <a href="#" class="dropdown-item">
                            <!-- Message Start -->
                            <div class="media">
                                <img src="~/img/user3-128x128.jpg" alt="User Avatar" class="img-size-50 img-circle mr-3">
                                <div class="media-body">
                                    <h3 class="dropdown-item-title">
                                        Nora Silvester
                                        <span class="float-right text-sm text-warning"><i class="fa fa-star"></i></span>
                                    </h3>
                                    <p class="text-sm">The subject goes here</p>
                                    <p class="text-sm text-muted"><i class="fa fa-clock-o mr-1"></i> 4 Hours Ago</p>
                                </div>
                            </div>
                            <!-- Message End -->
                        </a>
                        <div class="dropdown-divider"></div>
                        <a href="#" class="dropdown-item dropdown-footer">See All Messages</a>
                    </div>
                </li>
                <!-- 通知 -->
                <li class="nav-item dropdown">
                    <a class="nav-link" data-toggle="dropdown" href="#">
                        <i class="far fa-bell"></i>
                        <span class="badge badge-warning navbar-badge">15</span>
                    </a>
                    <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
                        <span class="dropdown-header">15 Notifications</span>
                        <div class="dropdown-divider"></div>
                        <a href="#" class="dropdown-item">
                            <i class="fa fa-envelope mr-2"></i> 4 new messages
                            <span class="float-right text-muted text-sm">3 mins</span>
                        </a>
                        <div class="dropdown-divider"></div>
                        <a href="#" class="dropdown-item">
                            <i class="fa fa-users mr-2"></i> 8 friend requests
                            <span class="float-right text-muted text-sm">12 hours</span>
                        </a>
                        <div class="dropdown-divider"></div>
                        <a href="#" class="dropdown-item">
                            <i class="fa fa-file mr-2"></i> 3 new reports
                            <span class="float-right text-muted text-sm">2 days</span>
                        </a>
                        <div class="dropdown-divider"></div>
                        <a href="#" class="dropdown-item dropdown-footer">See All Notifications</a>
                    </div>
                </li>
                <li class="nav-item dropdown user user-menu">
                    <a class="nav-link" data-toggle="dropdown" href="#">
                        <i class="far fa-user-circle"></i>
                        <span class="hidden-xs" id="userNameShow">@ViewData["Account"]</span>
                        <i class="fas fa-caret-down"></i>
                    </a>

                    <div class="dropdown-menu dropdown-menu-sm dropdown-menu-right">
                        <a href="#" class="dropdown-item">
                            <i class="far fa-user mr-2"></i>个人信息
                        </a>
                        <a href="#" class="dropdown-item" onclick="modifyPass();">
                            <i class="fas fa-key mr-2"></i>修改密码
                        </a>
                        <div class="dropdown-divider"></div>
                        <a href="#" class="dropdown-item" onclick="logout();">
                            <i class="fas fa-power-off mr-2"></i>退出
                        </a>
                    </div>
                </li>
            </ul>
        </nav>
        <!-- /.navbar -->
        <!-- Main Sidebar Container -->
        <aside class="main-sidebar sidebar-dark-primary elevation-4">
            <!-- Brand Logo -->
            <a href="/Home/Index" class="brand-link">
                <img src="~/img/AdminLogo.png" alt="@ViewData["SoftName"]" class="brand-image img-circle elevation-3"
                     style="opacity: .8">
                <span class="brand-text font-weight-light">会员中心</span>
            </a>
            <!-- Sidebar -->
            <div class="sidebar">
                <!-- Sidebar user panel (optional) -->
                <div class="user-panel mt-3 pb-3 mb-3 d-flex">
                    <div class="image">
                        <img src="~/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image">
                    </div>
                    <div class="info">
                        <a href="#" class="d-block" id="userNameRoleShow">@ViewData["Account"]:@ViewData["RealName"]</a>
                    </div>
                </div>
                <!-- Sidebar Menu -->
                <nav class="mt-2">
                    <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
                        <li class="nav-item has-treeview menu-open">
                            <a href="#" class="nav-link active" data-id="201904052239231936">
                                <i class="nav-icon fas fa-car"></i>
                                <p>
                                    汽车管理
                                    <i class="right fa fa-angle-left"></i>
                                </p>
                            </a>
                            <ul class="nav nav-treeview " style="display: block;">
                                <li class="nav-item">
                                    <a href="/Car/AutoDetailsMember/Index" data-id="201904052242594034" class="nav-link active">
                                        <i class="nav-icon far fa-circle"></i>
                                        <p>车型管理</p>
                                    </a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </nav>
                <!-- /.sidebar-menu -->
            </div>
            <!-- /.sidebar -->
        </aside>

        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <div class="content-header">
                <div class="container-fluid">
                    <div class="row mb-2">
                        <div class="col-sm-6">
                            <h5 class="m-0 text-dark"></h5>
                        </div><!-- /.col -->
                        <div class="col-sm-6">
                            <ol class="breadcrumb float-sm-right">
                                <li class="breadcrumb-item"><a href="/Home/Index">控制台</a></li>
                                <li class="breadcrumb-item active">@ViewData["Title"]</li>
                            </ol>
                        </div><!-- /.col -->
                    </div><!-- /.row -->
                </div><!-- /.container-fluid -->
            </div>
            <!-- /.content-header -->
            <!-- Main content -->
            <div class="content">
                @RenderBody()
            </div>
            <!-- /.content -->
        </div>
        <!-- /.content-wrapper -->
        <!-- Control Sidebar -->
        <aside class="control-sidebar control-sidebar-dark">
            <!-- Control sidebar content goes here -->
        </aside>
        <!-- /.control-sidebar -->
        <!-- Main Footer -->
        <footer class="main-footer">
            <!-- To the right -->
            <div class="float-right pull-right hidden-xs">
                Version @AppVersionHelper.Version
            </div>
            <!-- Default to the left -->
            Copyright &copy; 2017-@DateTime.Now.Year <strong><a href="http://www.yuebon.com" target="_blank">Yuebon  </a>.</strong> All rights reserved.

        </footer>
    </div>

    <div class="modal fade" id="modifyPasswordFormModal" tabindex="-1" role="dialog" aria-labelledby="modifyPasswordFormModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <form class="form-horizontal" id="frmModifyPasswordSubmit" method="post" enctype="multipart/form-data">

                    <div class="modal-header bg-primary">
                        <h5 class="modal-title" id="modifyPasswordFormModalLabel">修改密码</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <div class="row">
                                <label for="Password" class="col-form-label col-3 text-right">密码:</label>
                                <input type="password" class="form-control col-9 required" name="Password" id="Password" placeholder="请填写密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="row">
                                <label for="Password" class="col-form-label col-3 text-right">再输一次:</label>
                                <input type="password" class="form-control col-9 " name="Password2" id="Password2" placeholder="请重复填写密码">
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary btnSave" id="btnSavePasswordOK"><i class="fa fa-save"></i>保存</button>
                        <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-close"></i>关闭</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!-- ./wrapper -->
    <!-- PAGE SCRIPTS -->
    <script src="~/js/site.js"></script>
    <script type="text/javascript">
        $(function () {
            toastr.options = {
                "positionClass": "toast-top-center",//弹出窗的位置
                "showDuration": "300",//显示的动画时间
                "hideDuration": "1000",//消失的动画时间
                "timeOut": "2000", //展现时间
                "extendedTimeOut": "1000",//加长展示时间
            };
            BindSaveSavePasswordEvent();
        })
        function logout() {
            $.ajax({
                url: "/Shop/Members/Logout",
                data: "",
                dataType: 'json',//服务器返回json格式数据
                type: 'post',//HTTP请求类型
                timeout: 100000,//超时时间设置为10秒；
                success: function (data) {
                    window.location.href = "/MemberLogin/Index/";
                },
                error: function (data) {
                    window.location.href = "/MemberLogin/Index";
                }
            });
        }
        //绑定保存按钮的事件，修改密码
        function BindSaveSavePasswordEvent() {
            $("#btnSavePasswordOK").click(function () {
                $("#frmModifyPasswordSubmit").validate({
                    rules: {
                        Password: {
                            required: true,
                            minlength: 6
                        },
                        Password2: {
                            required: true,
                            minlength: 6
                        }
                    },
                    messages: {
                        Password: {
                            required: "请填写密码",
                            minlength: "密码至少6个字符"
                        },
                        Password2: {
                            required: "请重复填写密码",
                            minlength: "密码至少6个字符"
                        },
                    },
                    errorClass: 'help-block help-block-error',
                    focusInvalid: true,
                    highlight: function (element) {//验证未通过
                        $(element).closest('.form-group').addClass('has-error');
                    },
                    success: function (label, element) {
                        $(element).closest('.form-group').removeClass('has-error');
                        $(element).attr("title", "").tooltip("hide");
                    },
                    errorPlacement: function (error, element) {
                        if ($(element).next("div").hasClass("tooltip")) {
                            $(element).attr("data-original-title", $(error).text()).tooltip("show");
                        } else {
                            $(element).attr("title", $(error).text()).tooltip("show");
                        }
                    },
                    submitHandler: function (form) {
                        var postdata = {
                            password: $("#Password").val(),
                            password2: $("#Password2").val()
                        };
                        $.ajax({
                            url: "/MemberHome/ModifyPassword",
                            data: postdata,
                            dataType: 'json',//服务器返回json格式数据
                            type: 'post',//HTTP请求类型
                            timeout: 100000,//超时时间设置为10秒；
                            success: function (data) {
                                //服务器返回响应，根据响应结果，分析是否登录成功；
                                if (data.Success) {
                                    $('#modifyPasswordFormModal').modal('hide');  //手动显示
                                    toastr.success("修改密码成功！");
                                    $("#btnSavePasswordOK")[0].reset();
                                } else {
                                    toastr.warning(data.ErrMsg);
                                }
                            },
                            error: function (data) {
                                toastr.warning("您未被授权使用该功能，请联系管理员进行处理。");
                            }
                        });
                    }
                });
            });
        }
        function modifyPass() {
            $('#modifyPasswordFormModal').modal('show');  //手动显示
        }

    </script>
</body>
</html>
